package com.kandinfo.isbnmanage.quartz;

import java.util.Date;

import org.quartz.DisallowConcurrentExecution;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.kandinfo.base.common.util.DateUtils;
import com.kandinfo.isbnmanage.service.IsbnQuartzService;

/**
 * isbn管理数据挖掘定时器
 * 
 * @author qiweiyang
 *
 */
@DisallowConcurrentExecution// 不允许并发执行 
public class HandleIsbnDigJob {
	
	private final static Logger LOG = LoggerFactory.getLogger(HandleIsbnDigJob.class);
	private final static Object LOCK = new Object();
	private static Boolean running_flag = false;
	
	@Autowired
	IsbnQuartzService isbnQuartzService;
	
	public void work(){
		synchronized (LOCK) {
			if (running_flag) {
				LOG.debug("HandleIsbnDigJob is running time:" + new Date());
				return;
			}
			LOG.debug("HandleIsbnDigJob START");
			running_flag = true;
			Long start = System.currentTimeMillis();
			
			isbnQuartzService.dig();
			
			Long end = System.currentTimeMillis();
			LOG.debug("HandleIsbnDigJob END cost time："+DateUtils.getTimeDisplay(end.longValue()-start.longValue()));
			running_flag = false;
		}
	}

}
